package com.example.testmap;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import com.example.testmap.models.Bicloo;
import com.example.testmap.models.Marguerite;
import com.example.testmap.models.Tan;
import com.example.testmap.util.Util;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class MainActivity extends Activity {
    GoogleMap map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
        map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
        
        Intent intent = getIntent();
        int category = intent.getIntExtra(MenuActivity.EXTRA_CATEGORY,0);
        
        switch (category)
        {
        case 0 : ajoutMarkeursMarguerites();
        case 1 : ajoutMarkeursBicloos();
        case 2 : ajoutMarkeursTan();
      //  case 3 : ajoutMarkeursBicloos();

        	
        	
        }
        
    }
    
    
    public void ajoutMarkeursTan(){
    	
    	List<Tan> listeTan = Util.getListTan();
    	
    	for (Tan tan : listeTan){
    		
    		map.addMarker(new MarkerOptions().position(new LatLng(tan.getLat(), tan.getLng())).title(tan.getNomStation()));
    	}
    	}
    
public void ajoutMarkeursMarguerites(){
	
	List<Marguerite> listeMarguerite = Util.getListMarguerite();
	
	for (Marguerite marguerite : listeMarguerite){
		
		map.addMarker(new MarkerOptions().position(new LatLng(marguerite.getLat(), marguerite.getLng())).title(marguerite.getNomStation()));
	}
	}

public void ajoutMarkeursBicloos(){
	
	Map<String, Bicloo> mapBicloo = Util.getStationsbiclooList();
	
	Collection<Bicloo> collecBicloo = mapBicloo.values();
	for (Bicloo bicloo : collecBicloo){
		
		map.addMarker(new MarkerOptions().position(new LatLng(bicloo.getLat(), bicloo.getLng())).title(bicloo.getNomStation()));
	}
	}


}